<template>
	<view id="page">
		<nav-bar :navH="navH" :isTabar="false" :isHome="false" :pageName="title"></nav-bar>
		<view class="nav">
			<block v-for="(it, k1) in navs" :key="k1">
				<view class="nav-i" @click="goCate(it.id, it.type_name)">
					<image :src="it.icon" lazy-load="true"></image>
					<text>{{it.type_name}}</text>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
	import app from '../../common/index.js'
	export default {
		data() {
			return {
				title: '分类',
				navH: null,
				navs: [],
			}
		},
		onLoad() {
			this.navH = this.$store.state.navHeight;
			this.getNavs();
		},
		methods: {
			/**
			 * @des 获取分类
			 */
			getNavs() {
				app.request({
					url: 'entry/wxapp/type',
					data: {
						pagesize: 50,
					}
				}, (ret) => {
					let d = ret.data;
					this.navs = d.data;
				})
			},
			/**
			 * @des 打开种类页面
			 */
			goCate(id, name) {
				uni.navigateTo({
					url: '../category/index?id='+ id + '&n='+ name
				})
			},
		}
	}
</script>

<style>
</style>
